package com.morehair.controller.admin;

import com.morehair.bean.bo.admin.CommentBo;
import com.morehair.bean.vo.admin.BaseRespVo;
import com.morehair.bean.vo.admin.CommentListVo;
import com.morehair.service.admin.CommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description:
 * Date: 2021/6/7
 * Time: 20:11
 * author: zhang wei
 */
@RestController
@RequestMapping("admin/comment")
public class CommentController {

    @Autowired
    CommentService commentService;

    @RequestMapping("list")
    @RequiresPermissions("admin:comment:list")
    public BaseRespVo getCommentList(Integer page,Integer limit,Integer userId,Integer valueId,String sort,String order){
        CommentListVo commentListVo = commentService.getCommentList(page,limit,userId,valueId,sort,order);
        return BaseRespVo.ok(commentListVo);
    }

    @RequestMapping("delete")
    @RequiresPermissions("admin:comment:delete")
    public BaseRespVo deleteComment(@RequestBody CommentBo commentBo) {
        boolean success = commentService.deleteCommentById(commentBo);
        return success ? BaseRespVo.ok() : BaseRespVo.fail("该条评论信息不存在");
    }
}
